package http

import http2 "net/http"

type HttpError struct {
	Code    int
	Message string
}

func (e *HttpError) Error() string {
	return e.Message
}

func (e *HttpError) Write(response http2.ResponseWriter) {
	response.WriteHeader(e.Code)
	response.Write([]byte(e.Message))
}

func NewHttpError(code int, message string) *HttpError {
	return &HttpError{
		Code:    code,
		Message: message,
	}
}
